import { useNavigate } from 'react-router-dom'
import './index.scss'
import type React from 'react'

type propsT = {
    url?:string,
    onClick?:()=>void,
    children:React.ReactNode
}

const TextLink = (props:propsT)=>{

    const navigate = useNavigate()
    function handleClick(){
        props.onClick && props.onClick()
        props.url && navigate(props.url)
    }
    return (
        <span className="text_link" onClick={()=>handleClick()}>
            { props.children }
        </span>
    )
}

export default TextLink